Ungated fixes extracted from harmony-one/harmony#5122 - #16
Conversation
Fork-free subset of harmony-one#5122: every fix here changes no epoch-gated behaviour, so nodes running it stay in consensus with the current network. Critical: - consensus: reject VIEWCHANGE senders not in the committee; a non-member signature left the M3 aggregate unverifiable against its bitmap - slash: skip external debt apportionment when total external stake is zero (divide by zero on fully undelegated delegators) - votepower: guard zero TotalEffectiveStake in Compute (divide by zero) - core: reject CXReceiptsProof with mismatched ShardIDs/CXShardHashes lengths or a nil merkle proof High: - consensus: bound pending receipt header epoch to current+1 and cap requeues of proofs whose shard state never arrives - types: CXReceiptsProof.Copy wrote CommitSig into CommitBitmap - state: bounds-check AddReward against the delegation snapshot Medium: - staking: apply MaxBLSPerValidator before BLS proof verification Low: - core: nil parent check in MayBalanceMigration; nil receiver in ContainsEmptyField; GetVMConfig returns a copy; empty payload guard in HandleNodeMessage; unreachable uint64 comparison removed; slot key slice aliasing fixed
Greptile SummaryThis PR extracts 14 ungated defensive and correctness fixes without changing protocol activation epochs.
Confidence Score: 4/5The PR does not appear safe to merge while validators that synchronize across the retained height can continue without the required emergency recovery ViewID floor. The previously reported recovery-floor failure remains: startup below the retained height leaves the floor at zero, and no post-synchronization path installs it after the node crosses that height. Files Needing Attention: consensus/recovery_view_id.go and cmd/harmony/main.go
|
| Filename | Overview |
|---|---|
| consensus/checks.go | Rejects view-change votes from senders outside the active committee. |
| consensus/consensus_block_proposing.go | Bounds pending receipt epochs and limits retries when source shard state is unavailable. |
| core/block_validator.go | Rejects missing merkle proofs and undersized shard-hash arrays before indexing them. |
| core/blockchain_impl.go | Validates incoming receipt structure and returns an isolated VM configuration copy. |
| core/state/statedb.go | Prevents reward distribution from indexing beyond the current delegation list. |
| core/state_processor.go | Returns a descriptive error when a migration header's parent block is unavailable. |
| core/types/cx_receipt.go | Correctly copies commit bitmaps and safely handles nil receipt-proof receivers. |
| staking/types/validator.go | Copies slot-key storage and rejects excessive key counts before proof verification. |
Reviews (2): Last reviewed commit: "fix: preserve v1.2 consensus compatibili..." | Re-trigger Greptile
| if headHeight < retainedBlock { | ||
| return 0, false, nil | ||
| } |
There was a problem hiding this comment.
When a mainnet shard-0 or shard-1 validator starts below the retained height and later synchronizes across it, this startup-only check leaves its recovery floor at zero. The validator then uses ordinary ViewIDs and sends messages that recovery-aware peers reject, preventing it from participating in consensus.
Summary
This PR extracts the 14 fixes marked
Gated: Nofrom harmony-one#5122.These changes do not depend on
StrictStateValidationEpoch, do not change its activation epochs, and do not include any of the fork-gated behavior from harmony-one#5122. They are intended to be safe to deploy without a protocol activation while remaining consensus-compatible with the current network.Included fixes
votepower.ComputewhenTotalEffectiveStakeis zero.ShardIDs/CXShardHasheslengths and nil merkle proofs.current + 1and cap requeues.CommitSigandCommitBitmapinto the correct fields.AddRewardagainst the delegation snapshot.MaxBLSPerValidatorbefore BLS proof verification.CXReceiptsProofreceiver.GetVMConfig.Explicitly excluded
All 14 rows marked
Gated: Yesin harmony-one#5122 are excluded, including the gated EVM, delegation, reward, vote-power, receipt-import, and validator-state behavior changes. This PR also contains noStrictStateValidationEpochconfiguration change.Provenance and scope
harmony-one/harmony:mainafter Reject abandoned branch hashes harmony-one/harmony#5106 and Guard emergency recovery ViewID transitions harmony-one/harmony#5107.TestComputeWithZeroTotalEffectiveStake; production code is unchanged.Testing
Regression coverage is included for every behavioral fix. Relevant packages include:
consensusconsensus/votepowercorecore/statecore/typesnode/harmonystaking/slashstaking/types